import React, { Component } from 'react';
import { base } from 'nc-lightapp-front';
const { NCModal, NCButton, NCTable } = base;
const { Header: NCModalHeader, Body: NCModalBody, Footer: NCModalFooter } = NCModal;
import './index.less';

class SearchSet extends Component {
    constructor(props) {
        super(props);
        this.confirmModal = this.confirmModal.bind(this);
        this.closeModal = this.closeModal.bind(this);
        this.initModal = this.initModal.bind(this);
        this.state = {
            oldData:{},
            json:{}
        }
        
    }
    // 获取父级多语
    getLanguage (json) {
        this.setState({
            json: json
        })
    }
    confirmModal() {
        const { form, getManageScope, getSearchSetOldData } = this.props;
        getManageScope();
        this.closeModal();
        this.setState({
            oldData: form.getAllFormValue('card1')
        })
        getSearchSetOldData(form.getAllFormValue('card1'));
        
    }
    closeModal() {
        this.props.onClose && this.props.onClose();
    }
    initModal(){
        const { form } = this.props;
        form.setFormStatus('card1', 'edit');
        let meta = this.props.meta.getMeta();
        let psnJobItem = meta['card1'].items.find(item => item.attrcode === 'busiregion');
        psnJobItem.options = [
        {
            value: '',
            display: ''
        },
        {
            value: 'PSNDOC00000000000000',
            display: this.state.json['hi6007-000259'] //人事管理
        },
        {
            value: 'PSNPACT0000000000000',
            display:  this.state.json['hi6007-000260']//合同管理
        }, {
            value: 'SALARY00000000000000',
            display: this.state.json['hi6007-000261'] //薪酬管理
        }]
        this.props.meta.setMeta(meta);
        if (this.state.oldData.rows) {
            this.props.form.setAllFormValue({
                'card1': this.state.oldData
            })
        }
        form.setFormItemsDisabled('card1', { 'sourceentity': true })
        form.setFormItemsDisabled('card1', { 'target': true })

       
    }
    render() {
        const {
            form
        } = this.props;
        const { createForm } = form;
        const { visible } = this.props;

        return (
            <NCModal
                show={visible}
                size="sm"
                className="search-set-modal"
                onHide={this.closeModal}
                backdrop={'static'}
                onEntered={this.initModal}
            >
                <NCModalHeader closeButton={true}>
                    {/* 查询显示设置 */}
                    {this.state.json['hi6007-000269']}
                    </NCModalHeader>
                <NCModalBody>
                    {
                        createForm('card1', {
                            
                        })
                        
                    }

                </NCModalBody>
                <NCModalFooter>
                    <NCButton colors="primary" 
                        onClick={this.confirmModal}>
                        {/* 确定 */}
                        {this.state.json['hi6007-000004']}
                        </NCButton>
                    <NCButton
                        shape="border"
                        onClick={this.closeModal}
                    >
                        {/* 取消 */}
                        {this.state.json['hi6007-000005']}
                        </NCButton>
                </NCModalFooter>
            </NCModal>
        );
    }
}

export default SearchSet;



